In this step you will add the code to:
Note: Error handling is not included in the code samples.
Option Explicit Dim m_Application As New CRAXDDRT.Application Dim m_Report As CRAXDDRT.Report ' ************************************************************* 'DisplayReport is a procedure that ' - Enables the Tab control the first time a report is created ' or opened. ' - Sets the report object to the Embeddable Designer(CRDesigner1). ' - Disables the Help menu in the Embeddable Designer. ' - Sets the report object to the Crystal Report Viewer Control ' (CRViewer1). ' - Sets the Crystal Reports Viewer to view the report. ' Public Sub DisplayReport() ' Enable the tab control if disabled. If SSTab1.Enabled = False Then SSTab1.Enabled = True ' Set the Report Object CRDesignerCtrl1.ReportObject = m_Report ' Note---------------- ' Set all other properties for CRDesignerCtrl1 after setting the ' ReportObject property ' -------------------- ' Disable the Help menu CRDesignerCtrl1.EnableHelp = False ' Set the report source CRViewer1.ReportSource = m_Report ' Set the viewer to view the report CRViewer1.ViewReport ' Set the zoom level to fit the page ' to the width of the viewer window CRViewer1.Zoom 1 End Sub ' ************************************************************* Private Sub Form_Load() 'Set the tab control to display the Designer tab 'when the form is loaded SSTab1.Tab = 0 End Sub ' ************************************************************* Private Sub SSTab1_Click(PreviousTab As Integer) ' Refresh the report when clicking Preview, ' without refreshing the data from the server. If PreviousTab = 0 Then CRViewer1.RefreshEx False End Sub ' ************************************************************* ' Create a new report and display it in the Embeddable Designer ' Private Sub cmdNew_Click() ' Set the report object to nothing Set m_Report = Nothing ' Create a new report Set m_Report = m_Application.NewReport ' Call DisplayReport to set the report to the Embeddable Designer ' and the Crystal Report Viewer and then display the report in the ' Embeddable Designer. Call DisplayReport End Sub ' ************************************************************* ' Use the Microsoft Common Dialog control to open a report. ' Private Sub cmdOpen_Click() CommonDialog1.CancelError = True On Error GoTo errHandler ' Display the open dialog box CommonDialog1.ShowOpen ' Set the report object to nothing Set m_Report = Nothing ' Open the selected report Set m_Report = m_Application.OpenReport(CommonDialog1.FileName, 1) ' Call DisplayReport to set the report to the Embeddable Designer ' and the Crystal Report Viewer Call DisplayReport Exit Sub errHandler: 'User cancelled dialog End Sub ' ************************************************************* Private Sub cmdAbout_Click() frmAbout.Show vbModal End Sub ' ************************************************************* Private Sub cmdExit_Click() Unload Me End Sub
To continue with this procedure, go to Step 3: Running the Embeddable Designer application (Microsoft Visual Basic).
Seagate Software IMG Holdings, Inc. http://www.seagatesoftware.com Support services: http://support.seagatesoftware.com |